package ru.aptu.socket_factory;

import java.io.IOException;
import java.net.Socket;

/**
 * Created by IntelliJ IDEA.
 * User: andrey
 * Date: 2/10/12
 * Time: 4:34 PM
 */
public final class ConnectionChecker {

    public static final int CHECK = 0;

    public static void checkClientConnection(Socket socket) throws IOException {
        socket.getOutputStream().write(CHECK);
    }

    public static void checkServerConnection(Socket socket) throws IOException {
        if (socket.getInputStream().read() != CHECK) {
            throw new IOException();
        }
    }
}
